<template>
    <header class="header">
        <div class="container">
            <div class="logo">
                <router-link to="/"><img src="@/assets/logo.png" alt="幼儿园Logo"></router-link>
            </div>
            <button class="menu-toggle" @click="toggleMenu" aria-label="Toggle navigation">
                &#9776;
            </button>
            <nav :class="{ 'is-active': menuActive }">
                <ul>
                    <li @click="closeMenu"><router-link to="/">首页</router-link></li>
                    <li @click="closeMenu"><router-link to="/about">关于我们</router-link></li>
                    <li @click="closeMenu"><router-link to="/courses">课程介绍</router-link></li>
                    <li @click="closeMenu"><router-link to="/join">加入我们</router-link></li>
                    <li @click="closeMenu"><router-link to="/contact">联系我们</router-link></li>
                </ul>
            </nav>
        </div>
    </header>
</template>

<script>
export default {
    name: 'Header',
    data() {
        return {
            menuActive: false
        }
    },
    methods: {
        toggleMenu() {
            this.menuActive = !this.menuActive;
        },
        closeMenu() {
            this.menuActive = false;
        }
    }
}
</script>

<style scoped>
/* ... (existing styles) ... */
.header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    position: relative; /* Added for mobile menu positioning */
}
.container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
.logo a {
    display: flex; /* Added for vertical alignment */
    align-items: center; /* Added for vertical alignment */
}
.logo img {
    height: 40px; /* Control the height of the logo */
    width: auto; /* Maintain aspect ratio */
}
nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
}
nav li {
    margin-left: 20px;
}
nav a {
    text-decoration: none;
    color: #333;
    font-size: 16px;
    transition: color 0.3s;
}
nav a:hover, .router-link-exact-active {
    color: #007bff;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

/* Responsive Styles */
@media (max-width: 768px) {
    nav {
        display: none;
        position: absolute;
        top: 100%; /* Position below the header */
        left: 0;
        width: 100%;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        z-index: 1000; /* Ensure it's on top */
    }
    nav.is-active {
        display: block;
    }
    nav ul {
        flex-direction: column;
        padding: 10px 0;
    }
    nav li {
        margin: 0;
        text-align: center;
    }
    nav a {
        display: block;
        padding: 10px;
    }
    .menu-toggle {
        display: block;
    }
}
</style>
